<template>
  <div class="betterScroll">
    <div class="containerBeauty">
      <div class="containerBeauty_title">
      </div>
      <van-tabs @click="toggle" v-model="menu.key">
        <van-tab v-for="key in menu" :title="key.name">
          <ul class="Beauty_content safe_padding">
            <li v-for="key in prodData">
              <div class="prodImage">
                <img :src="key.prodImage[0]" alt="">
              </div>
              <div class="prodInfo safe_padding">
                <span class="prodInfo_title">{{key.prodSupTitle}}</span>
                <span class="prodInfo_title">{{key.prodSubTitle}}</span>
                <p class="Coupon">券后价</p>
                <span class="prodInfo_price current_price">￥{{key.currentPrice}}</span>
                <span class="prodInfo_price origin_price">￥{{key.originPrice}}</span>
              </div>
            </li>
          </ul>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script>
    export default {
        name: "general",
      data() {
        return {
          menu: [
            {name: '9.9包邮', subCategoryName: 'freePost'},
            {name: '保温水杯', subCategoryName: 'waterCup'},
            {name: '洗护纸品', subCategoryName: 'cleanAndPaper'},
            {name: '身体护理', subCategoryName: 'careBody'},
          ],
          prod: {
            prodCategory: 'department',
            prodSubClass: 'freePost',
          },
          prodData: ''
        }
      },
      methods: {
        toggle(key) {
          console.log(this.menu[key].subCategoryName);
          this.prod.prodSubClass = this.menu[key].subCategoryName;
          this.getProd();
        },
        getProd() {
          this.$api.prod(this.prod).then((data) => {
            if (data.data.code === 10100) {
              console.log('商品数据获取成功');
              console.log(data);
              console.log(data.data.data);
              this.prodData = data.data.data;
            } else {
              console.log('商品数据获取失败');
              console.log(data.data.msg);
            }
          }).catch((error) => {
            console.log(error);
          })
        }
      },
      mounted() {
        this.getProd();
        this.scroller = new this.$BS('.betterScroll', {
          scrillX: false,
          scrollY: true,
          click: true,
        });
      },
      created(){
        /*  this.$api.prod(this.prod).then(data=>{
            console.log(data);
            console.log(data.data.data);
            this.prodData=data.data.data
          }).catch(error=>{
            console.log(error);
          })*/
      }
    }
</script>

<style lang="scss">
  * {
    margin: 0;
    padding: 0;
  }
  .betterScroll {
    width: 100vw;
    height: 93vh;
    overflow: hidden;
    position: relative;
    background: #f5f5f5;
  }

  .containerBeauty {
    width: 100vw;
    position: fixed;
    .container {
      padding-top: 0;
      box-sizing: border-box;
      width: 100vw;
      height: 9.8rem;
      background: #fff;
    }
    .containerBeauty_title {
      width: 100vw;
      height: 300px;
      background: #333;
      margin-top: 2.4rem;
    }
    .containerMenu {
      width: 100vw;
      height: 1.2rem;
      background: #fff;
    }
  }

  .Beauty_content {
    text-align: center;
    li {
      display: inline-block;
      width: 50%;
      height: 492px;
      text-align: center;
      float: left;
      margin-top: .2rem;
      .prodInfo{
        text-align: left;
        span{
          width: inherit;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
          font-size: 28px;
        }
        .prodInfo_title{
          display: block;
          color: #333;
        }
        .prodInfo_price{
          display: inline-block;
          line-height: 60px;
        }
        .current_price{
          color: #5e5e5e;
        }
        .origin_price{
          color: #acacac;
          text-decoration: line-through;
        }
        .Coupon{
          margin-top: .1rem;
          line-height: 36px;
          width: 100px;
          background: #0c99fe;
          text-align: center;
          color: #fff;
          border-radius: 18px;
        }
      }
      img {
        width: 250px;
        height: 300px;
      }
    }
    .safe_padding {
      padding-left: 30px;
      padding-right: 30px;
    }
  }
</style>
